// 引入 Mock.js
import Mock from 'mockjs';

// 模拟登录接口
Mock.mock('/api/login', 'post', (options) => {
  // 解析请求体中的数据
  const body = JSON.parse(options.body);
  const { mobile, password } = body;

  // 模拟账号和密码校验逻辑
  if (mobile === '13800000000' && password === '123456') {
    // 登录成功
    return {
      code: 10000,
      data: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImlhdCI6MTc0Mjc5Nzc4MywiZXhwIjoxNzQyODE5MzgzfQ.ELtIS9WuMyLdJYhmml70xgQPQxhYmltrjbazKhZ3VzQ",
      message: "登录成功",
      success: true
    };
  } else {
    // 登录失败
    return {
      code: 20000,
      data: null,
      message: "手机号或密码错误",
      success: false
    };
  }
});

// 启动 Mock.js
export default Mock;
